package com.expert.conrtoller;

import com.expert.annotations.RoleAnnotation;
import com.expert.enums.RoleLevel;
import com.expert.result.Result;
import com.expert.service.ExtractResultService;
import com.expert.service.StatisticService;
import com.expert.vo.ExtractStatistic;
import com.expert.vo.HomeStatisticVo;
import com.expert.vo.ProjectStatistic;
import com.expert.vo.StatisticData;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: StatisticController
 * @Author: cxs
 * @Date: 2024/03/29 19:03
 * @Description:
 **/
@RestController
@RequestMapping("/statistic")
@Slf4j
public class StatisticController {

    @Autowired
    StatisticService statisticService;

    /**
     * 用户信息统计
     * @param num
     * @return
     */
    @RoleAnnotation(level = RoleLevel.ADMIN)
    @GetMapping("/user/{num}")
    public Result<StatisticData> userStatistic(@PathVariable("num")Integer num){
        log.info("用户数据统计");
        StatisticData statisticData=this.statisticService.userStatistic(num);
        return Result.success(statisticData);
    }

    /**
     * 专家信息统计
     * @param num
     * @return
     */
    @RoleAnnotation(level = RoleLevel.ADMIN)
    @GetMapping("/expert/{num}")
    public Result<StatisticData> expertStatistic(@PathVariable("num")Integer num){
        log.info("专家数据统计");
        StatisticData statisticData=this.statisticService.expertStatistic(num);
        return Result.success(statisticData);
    }

    /**
     * 项目信息
     * @param num
     * @return
     */
    @RoleAnnotation(level = RoleLevel.ADMIN)
    @GetMapping("/project/{num}")
    public Result<ProjectStatistic> projectStatistic(@PathVariable("num")Integer num){
        log.info("专家数据统计");
        ProjectStatistic statisticData=this.statisticService.projectStatistic(num);
        return Result.success(statisticData);
    }
    /**
     * 评审信息
     * @param num
     * @return
     */
    @RoleAnnotation(level = RoleLevel.ADMIN)
    @GetMapping("/extract/{num}")
    public Result<ExtractStatistic> extractStatistic(@PathVariable("num")Integer num){
        log.info("专家数据统计");
        ExtractStatistic statisticData=this.statisticService.extractStatistic(num);
        return Result.success(statisticData);
    }

    /**
     * 专家库首页统计
     * @return
     */
    @GetMapping("/homeStatistic")
    public Result<HomeStatisticVo> homeStatistic(){
        log.info("首页信息统计");
        HomeStatisticVo homeStatisticVo=this.statisticService.homeStatistic();
        return Result.success(homeStatisticVo);
    }
}
